<template>
	<view class="user" :class="[isDark?'dark':'', $store.state.AppStyle]" :style="{'background-color':isDark?'#1c1c1c':'#f6f6f6','min-height':isDark?'100vh':'auto'}">
		<view class="header" :style="[{height:CustomBar + 'px'}]">
			<view class="cu-bar" :class="isDark?'dark':'bg-white'" :style="{'height': CustomBar + 'px','padding-top':StatusBar + 'px','background-color':isDark?'#1c1c1c':'#ffffff'}">
				<view class="action" @tap="back">
					<text class="cuIcon-back"></text>
				</view>
				<view class="content text-bold" :style="[{top:StatusBar + 'px'}]">
					{{$t('identify.company.bluevapply')}}
				</view>
			</view>
		</view>
		<view :style="[{padding:NavBar+5 + 'px 10px 0px 10px'}]"></view>
		<form>
			<view class="cu-form-group">
				<view class="title">{{$t('identify.company.applyreason')}}</view>
				<input placeholder="$t('identify.company.plsapplyreason')" v-model="entname" name="input"/>
			</view>
			<view class="cu-form-group">
				<view class="title">{{$t('identify.company.authtitle')}}</view>
				<input placeholder="$t('identify.company.plsauthtitle')" v-model="name" name="input"/>
			</view>
			<view class="all-btn margin-top">
				<view class="user-btn flex flex-direction">
					<button class="cu-btn bg-blue margin-tb-sm lg" @tap="company">{{$t('identify.company.applyforsubmit')}}</button>
				</view>
			</view>
		</form>

	</view>
</template>

<script>
	import { localStorage } from '../../js_sdk/mp-storage/mp-storage/index.js'
	import darkModeMixin from '@/utils/darkModeMixin.js'
	export default {
		mixins: [darkModeMixin],
		data() {
			return {
				StatusBar: this.StatusBar,
				CustomBar: this.CustomBar,
				NavBar:this.StatusBar +  this.CustomBar,
				AppStyle:this.$store.state.AppStyle,
				
				uid:0,
				idcard:"",
				name:"",
				regno:"",
				entname:"",
				
				userInfo:"",
				token:'',
			}
		},
		onPullDownRefresh(){
			
			
		},
		onShow(){
			var that = this;
			// #ifdef APP-PLUS
			
			//plus.navigator.setStatusBarStyle("dark")
			// #endif
			if(localStorage.getItem('token')){
				
				that.token = localStorage.getItem('token');
			}
			that.getCacheInfo();
		},
		onLoad() {
			var that = this;
			// #ifdef APP-PLUS || MP
			that.NavBar = that.CustomBar;
			// #endif
		},
		methods: {
			back(){
				uni.navigateBack({
					delta: 1
				});
			},
			getCacheInfo(){
				var that = this;
				if(localStorage.getItem('userinfo')){
					var userInfo = JSON.parse(localStorage.getItem('userinfo'));
					that.uid=userInfo.uid;
					that.userInfo = userInfo;
				}
			},
			company() {
				var that = this;
				if(that.entname==""){
					uni.showToast({
						title: that.$t('identify.company.plsreasonapply'),
						icon: 'none'
					})
					return false;
				}
				if(that.name==""){
					uni.showToast({
						title: that.$t('identify.company.plsauthtitle'),
						icon: 'none'
					})
					return false;
				}
				var data = {
					name:that.name,
					idcard:"1",
					regno:"1",
					entname:that.entname,
				}
				uni.showLoading({
					title: that.$t('common.loadmore')
				});
				that.$Net.request({
					
					url: that.$API.addCompany(),
					data:{
						"params":JSON.stringify(that.$API.removeObjectEmptyKey(data)),
						"token":that.token
					},
					header:{
						'Content-Type':'application/x-www-form-urlencoded'
					},
					method: "get",
					dataType: 'json',
					success: function(res) {
						setTimeout(function () {
							uni.hideLoading();
						}, 1000);
						uni.showToast({
							title: res.data.msg,
							icon: 'none'
						})
						if(res.data.code==1){
							uni.showToast({
								title: that.$t('identify.company.submitsuccess'),
								icon: 'none'
							})
							setTimeout(function () {
								that.back();
							}, 1000);
							
							
						}
						
					},
					fail: function(res) {
						setTimeout(function () {
							uni.hideLoading();
						}, 1000);
						uni.showToast({
							title: that.$t('common.networkfail'),
							icon: 'none'
						})
						uni.stopPullDownRefresh()
					}
				})
			},
		}
	}
</script>

<style>
</style>
